package com.ctshk.rpc.scenic.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.scenic.entity.ScenicProductChannelOfflineSelfCustom;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author xuhui
 * @since 2/2/2021
 */
public interface ScenicProductChannelOfflineSelfCustomMapper extends BaseMapper<ScenicProductChannelOfflineSelfCustom> {
    /**
     * 清空门票线下自营自定义权限
     * @param
     * @param
     */
    @Update("UPDATE t_scenic_product_channel_offline_self_custom \n" +
            "SET is_deleted = 1 \n" +
            "WHERE product_id = #{product_id}")
    Integer clearByProductId(@Param("product_id") Long productId);


    @Select("SELECT * from t_scenic_product_channel_offline_self_custom \n" +
            "where offline_id in (${OfflineIds}) \n" +
            " or ( (check_type =1 and  relation_id = #{deptId} )or (check_type=2 and relation_id=#{userId}))" +
            " ORDER BY check_type ASC ")
    List<ScenicProductChannelOfflineSelfCustom> queryByOfflineIds(@Param("OfflineIds") String OfflineIds,
                                                                  @Param("userId")Long userId,
                                                                  @Param("deptId")Long deptId);

}
